$(function(){
    $('.carousel').carousel({
        interval: 5000,
        pause: 'none'
    })
    $("#login").click(function(){
        let username = $("#username").val();
        let password = $("#password").val();
        let verify_code = $("#verify_code").val();
        if(!username){
            layer.tips('请填写用户名', '#username', {
                tips: [1, 'orangered'],
                time: 3000
            });
            $("#username").focus();
            return;
        }
        if(!password){
            layer.tips('请填写密码', '#password', {
                tips: [1, 'orangered'],
                time: 3000
            });
            $("#password").focus();
            return;
        }
        if(!verify_code){
            layer.tips('请填写验证码', '#verify_code', {
                tips: [1, 'orangered'],
                time: 3000
            });
            $("#verify_code").focus();
            return;
        }
        $.ajax({
            url: '/admin-login-submit',
            type: 'post',
            data: {username:username, password:password, verify_code:verify_code},
            success: function(data){
                if(!data.bool){
                    layer.msg(data.msg, {
                        icon: 5,
                        offset: '150px'
                    });
                }else{
                    window.location.href = '/';
                }
            }
        })
    })
})